public class IsLegal extends Sudoku{
	
	
	public static boolean isLegal(int[][] board) {
	// Check the nine blocks.
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 2, 0, 2, "Block 1")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 3, 5, 0, 2, "Block 2")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 6, 8, 0, 2, "Block 3")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 2, 3, 5, "Block 4")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 3, 5, 3, 5, "Block 5")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 6, 8, 3, 5, "Block 6")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 2, 6, 8, "Block 7")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 3, 5, 6, 8, "Block 8")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 6, 8, 6, 8, "Block 9")) return false;
 
	// check the nine columns
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 0, 0, 8, "Column 0")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 1, 1, 0, 8, "Column 1")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 2, 2, 0, 8, "Column 2")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 3, 3, 0, 8, "Column 3")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 4, 4, 0, 8, "Column 4")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 5, 5, 0, 8, "Column 5")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 6, 6, 0, 8, "Column 6")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 7, 7, 0, 8, "Column 7")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 8, 8, 0, 8, "Column 8")) return false;
 
	// check the nine rows
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 0, 0, "Row 0")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 1, 1, "Row 1")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 2, 2, "Row 2")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 3, 3, "Row 3")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 4, 4, "Row 4")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 5, 5, "Row 5")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 6, 6, "Row 6")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 7, 7, "Row 7")) return false;
	if (!IsRectangleLegal.isRectangleLegal(board, 0, 8, 8, 8, "Row 8")) return false;
	return true;
    }
	
	
}